﻿
using GameServer.Network;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Summer.Network;
using Proto;
using Common;
using Serilog;
using GameServer.Service;
using GameServer.Database;
using GameServer.Mgr;
using Summer;

namespace GameServer
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //初始化日志环境
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug() //debug , info , warn , error
                .WriteTo.Async(a => a.Console())
                .WriteTo.Async(a => a.File("logs\\server-log.txt", rollingInterval: RollingInterval.Day))
                .CreateLogger();


            //Db.fsql.Insert(new DbPlayer()).ExecuteAffrows();
            //Db.fsql.Insert(new DbCharacter()).ExecuteAffrows();

            //加载JSON配置文件
            DataManager.Instance.Init();

            //网路服务模块
            NetService netService = new NetService();
            netService.Start();
            Log.Debug("网络服务启动完成");

            UserService userService = UserService.Instance;
            userService.Start();
            Log.Debug("玩家服务启动完成");

            SpaceService spaceService = SpaceService.Instance;
            spaceService.Start();
            Log.Debug("地图服务启动完成");



            Schedule.Instance.Start();
            Log.Debug("中心计时器启动完成");


            //消息订阅：用户登录请求
            //MessageRouter.Instance.Subscribe<UserLoginRequest>(OnUserLoginRequest);
            //Log.Debug("用户登录请求的订阅");

            while (true)
            {
                Thread.Sleep(100);
            }
        }

        
    }
}